package cn.ybk.basic.eum;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

// 店铺的状态枚举
@Getter
@AllArgsConstructor
public enum ShopStateEnum {

    WAIT_AUDIT(0, "待审核"),
    WAIT_ACTIVE(1, "待激活"),
    HAVING_ACTIVE(2, "已激活"),
    NO_AUDIT(3, "驳回"),

    ;

    // 根据传进来的 code 返回对应的name 比如传入0 那么返回 待审核
    public static String getNameByCode(int code) {
        Optional<ShopStateEnum> first = Arrays.stream(ShopStateEnum.values())
                .filter(en -> en.getCode() == code).findFirst();
        if (!first.isPresent()) {
            return "";
        }
        return first.get().getName();
    }

    // code值
    private int code;
    // 名称
    private String name;
}
